#pragma once
#include <vector>
#include "string.h"
#include "netcdf.h"
#include <unordered_map>

#define FILE_NAME "E:\\\\merra2_3d\\MERRA2_400.inst3_3d_aer_Nv.20231003.nc4"
/* We are reading 4D data, a 2 x 6 x 12 lvl-lat-lon grid, with 2
   timesteps of data. */
#define NDIMS 4
#define NLAT 361
#define NLON 576
#define LAT_NAME "lat"
#define LON_NAME "lon"
#define NREC 8
#define REC_NAME "time"
#define LVL_NAME "lev"
#define NLVL 72
#define MSA_NAME "MSA"

   /* Names of things. */
#define PRES_NAME "pressure"
#define TEMP_NAME "temperature"
#define UNITS "units"
#define DEGREES_EAST "degrees_east"
#define DEGREES_NORTH "degrees_north"

/* These are used to calculate the values we expect to find. */
#define SAMPLE_PRESSURE 900
#define SAMPLE_TEMP 9.0
#define START_LAT 25.0
#define START_LON -125.0

/* For the units attributes. */
#define UNITS "units"
#define PRES_UNITS "hPa"
#define TEMP_UNITS "celsius"
#define LAT_UNITS "degrees_north"
#define LON_UNITS "degrees_east"
#define MAX_ATT_LEN 80

/* Handle errors by printing an error message and exiting with a
 * non-zero status. */
#define ERR(e) {printf("Error: %s\n", nc_strerror(e)); return 2;}
const float infini1 = -99999.0;

static const int nThreadsNum = 4;
static const int CBLK = 8;
static long num_steps = 10000000;
static const int ArraySize = 1000;

struct Coord2Dim { int dims; int d1; int d2; int d3; int d5; int d6;};
struct CoordDim { int dim1; int dim2; int dim3; int dim4; };
struct Coord2D { float lat; float lon; };
struct Coord2Dt { 
    int time;  
    float lat; 
    float lon;
    float value;
};
struct Coord3Dv { 
    float lat; 
    float lon; 
    float lev; 
};
struct Coord3Dt { 
    int time; 
    float lat; 
    float lon; 
    float values; 
    Coord3Dt() :time(-1),lat(infini1),lon(infini1),values(infini1){}
};
struct Coord4Dt {
    int time;
    float lev;
    float lat;
    float lon;
    float values;
    Coord4Dt() :time(-1), lat(infini1), lon(infini1), values(infini1) {}
};
struct Coord4D { float lat; float lon; float lev; int time; };

typedef struct basemes_of_values {
    std::vector<std::string> values_list;
    std::unordered_map<std::string, unsigned> dims;
    std::unordered_map<std::string, unsigned> size;
    std::unordered_map<Coord2D, float> prectot;
    std::unordered_map<Coord2D, float> t2mmax;
    std::unordered_map<Coord2D, float> t2mmean;
    std::unordered_map<Coord2D, float> t2mmin;
    std::unordered_map<Coord2D, float> time;
}basemes_of_values;


